package com.jiazhong.集合类.Collection.List.LinkedListDemo;

import java.util.LinkedList;

public class LinkedListToStack {
    public static void main(String[] args) {
        LinkedList<String> stack=new LinkedList<>();
        //入栈
        stack.push("111");
        stack.push("222");
        stack.push("333");
        stack.push("444");
        System.out.println(stack);
        System.out.println(stack.pop());

        String poll=stack.poll();
        System.out.println(poll);
        System.out.println(stack.poll());
        System.out.println(stack.poll());
        System.out.println(stack.poll());//栈为空返回null值
        System.out.println(stack.pop());//栈为空报错
        System.out.println(stack);
    }
}
